<script src="/js/Register.js?{echo time();}"></script>
<script src="/js/addAdress.js?{echo time();}"></script>
<h1>zarejestruj się </h1>
{if isset($success)}
<h1 class="alert-success">    
    Twoje konto zostało pomyślnie utworzone      
</h1>
{/if}  
{else}
<form role="form" class="form-horizontal" id="formRegister" method="post" action="">
    <input type="hidden" name="inputRegisterShop" value="$shop">
    <div class="form-group">
        <label class="col-lg-3" for="inputRegisterName">Imię</label>
        <input name="inputRegisterName" required class="col-lg-2 input-sm" type="text" id="inputRegisterName" placeholder="wpisz swoje imię" pattern="[ąćęńśóźłża-zA-Z]+" maxlength="30" title="Imię może składać się tylko z dużych i małych liter" value="$person->Name">        
        {if isset($errors)}
        <span class="alert-danger">{echo \view\View::showErrors($errors, "Name")}</span>
        {/if}

    </div>
    <div class="form-group">
        <label class="col-lg-3" for="inputRegisterSurname">Nazwisko</label>
        <input name="inputRegisterSurname" required class="col-lg-2 input-sm" type="text" id="inputRegisterSurname" placeholder="wpisz swoje nazwisko" pattern="[ąćęńśóźżła-zA-Z]+" maxlength="30" title="Nazwisko może składać się tylko z dużych i małych liter" value="$person->Surname">         
        {if isset($errors)}
        <span class="alert-danger">{echo \view\View::showErrors($errors, "Surname")}</span>
        {/if}

    </div>
    <div class="form-group">
        <label class="col-lg-3" for="inputRegisterPostCode">Kod pocztowy</label>
        <input name="inputRegisterPostCode" onblur="findAdress();" required class="col-lg-2 input-sm" type="text" id="inputRegisterPostCode" placeholder="wpisz kod pocztowy" pattern="\d\d-\d\d\d" maxlength="6" title="wprowadź dane w formacie 00-000">  
        <img class="hidden" id="Wait" src="/img/loading.gif">  
        <p id="PostCodeError" class="col-xs-6 alert-danger hidden"></p>
    </div>
    <div class="hidden">
        <div class="form-group">
            <label class="col-lg-3">Województwo</label>
            <p id="Region">dad</p>  
        </div>
        <div class="form-group">
            <label class="col-lg-3">Powiat</label>
            <p id="District">dad</p>  
        </div>
        <div class="form-group">
            <label class="col-lg-3">Gmina</label>
            <p id="Community">dad</p>  
        </div>
        <div class="form-group" >
            <label class="col-lg-3" for="inputRegisterCity">Miasto</label>
            <div id="City">

            </div>
        </div>
        <div class="form-group hidden">
            <label class="col-lg-3" for="inputRegisterStreet">Ulica</label>
            <div id="Street">

            </div>
        </div>
        <div class="form-group" >
            <label class="col-lg-3" for="inputRegisterCity">Numer Domu/Mieszkania</label>
            <input name="inputRegisterNumber" id="inputRegisterNumber" required class="col-lg-2 input-sm" type="text" id="inputRegisterNumber" placeholder="Numer Domu/Mieszkania" maxlength="7" >  
        </div>
    </div>
    <div class="form-group">
        <label class="col-lg-3" for="inputRegisterEmail">E-mail</label>
        <input required class="col-lg-2 input-sm" type="email" id="inputRegisterEmail" placeholder="wpisz swój adres email" name="inputRegisterEmail" value="$person->Email">  
        {if isset($errors)}
        <span class="alert-danger">{echo \view\View::showErrors($errors, "Email")}</span>
        {/if}
        {if isset($emailError)}
        <span class="alert-danger">$emailError</span>
        {/if}
    </div>
    <div class="form-group">
        <label class="col-lg-3" for="inputRegisterPhone">Numer telefonu</label>
        <input name="inputRegisterPhone" required class="col-lg-2 input-sm" pattern="\d\d\d(\s|-)?\d\d\d(\s|-)?\d\d\d" type="text" id="inputRegisterPhone" placeholder="wpisz swój numer telefonu" value="$person->PhoneNumber">         
        {if isset($errors)}
        <span class="alert-danger">{echo \view\View::showErrors($errors, "PhoneNumber")}</span>
        {/if}

    </div>
    <div class="form-group">
        <label class="col-lg-3" for="inputRegisterPassword">Hasło</label>
        <input onkeyup="checkPassword();" required class="col-lg-2 input-sm" type="password" id="inputRegisterPassword"  name="inputRegisterPassword" placeholder="wpisz swoje hasło" maxlength="20" >       
        <span id="inputRegisterPasswordError" class="alert-danger">
            {if isset($errors)}
            {echo \view\View::showErrors($errors, "Password")}
            {/if}
        </span>
    </div>
    <div class="form-group">
        <label class="col-lg-3" for="inputRegisterPasswordRepeat">Powtórz hasło </label>
        <input required class="col-lg-2 input-sm" type="password" id="inputRegisterPasswordRepeat" name="inputRegisterPasswordRepeat" placeholder="powtórz swoje hasło" maxlength="20" onkeyup="checkPassword();">    
        <span id="inputRegisterPasswordRepeatError" class="alert-danger"></span>
    </div>
    <input name="inputRegisterSubmit" type="submit" id="inputRegisterButton" value="załóż konto">
</form>

<script type="text/javascript">
    var shop = "$shop";
    $(".form-group").bind("contextmenu", function(e) {
        //return false; // blokujemy menu kontekstowe
    });
    $("#formRegister").submit(register);
</script>
{/else}
